package com.eco.fanliapp.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.dao.GoodsIdSetupMapper;
import com.eco.fanliapp.entity.GoodsIdSetup;
import com.eco.fanliapp.service.IGoodsIdSetupService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author jobob
 * @since 2019-12-25
 */
@Service
public class GoodsIdSetupServiceImpl extends ServiceImpl<GoodsIdSetupMapper, GoodsIdSetup> implements IGoodsIdSetupService {

    @Autowired
    private GoodsIdSetupMapper goodsIdSetupMapper;

    @Override
    public ServerResponse addGood(Long goodId) {
        GoodsIdSetup goodsIdSetup = new GoodsIdSetup();
        goodsIdSetup.setGoodsId(goodId);
        int insert = goodsIdSetupMapper.insert(goodsIdSetup);
        if(insert > 0){
            return ServerResponse.createBySuccessMessage("新增成功");
        }
        return ServerResponse.createByErrorMessage("新增失败");
    }

    @Override
    public ServerResponse GoodsIdSetupList(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<GoodsIdSetup> goodsIdSetups = goodsIdSetupMapper.GoodsIdSetupList();
        return ServerResponse.createBySuccess("查询成功",new PageInfo(goodsIdSetups));
    }


}
